package com.iweb.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iweb.mapper.CommentMapper;
import com.iweb.model.Comment;
import com.iweb.model.Game;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CommentService {
    @Resource
    private CommentMapper commentMapper;


    public List<Comment> selectCommentByGameId(Integer page,Integer gameId) {
        PageHelper.startPage(page,10);

        List<Comment> comments = commentMapper.selectByGameId(gameId);

        PageInfo<Comment> info = new PageInfo<>(comments);

        return info.getList();
    }

    public List<Comment> selectByUserId(Integer userId) {
        List<Comment> comments = commentMapper.selectByUserid(userId);
        return comments;
    }



    public void greatCommentById(Integer commentId) {
        commentMapper.updateGreatByCommentId(commentId);
    }

    public void badCommentById(Integer commentId) {
        commentMapper.updateBadByCommentId(commentId);
    }

    public void insertComment(Comment comment) {
        commentMapper.insertComment(comment);
    }

    public void deleteByCommentId(Integer commentId) {
        commentMapper.deleteById(commentId);
    }

    public void badMinusById(Integer commentId) {
        commentMapper.updateBadMinusById(commentId);
    }

    public void goodMinusById(Integer commentId) {
        commentMapper.updateGoodMinusById(commentId);
    }
}
